<template>
  <div class="addAddr">
    <van-address-edit :area-list="areaList" show-postal show-search-result :search-result="searchResult" :area-columns-placeholder="['请选择', '请选择', '请选择']" @save="onSave" @delete="onDelete" @change-detail="onChangeDetail">
      <template #show-delete>
        <div>

        </div>
      </template>
      <template #show-set-default>
        <div>

        </div>
      </template>
    </van-address-edit>
  </div>
</template>
<script>
import { Toast } from 'vant'
export default {
  data() {
    return {
      areaList: this.$store.state.address.areaList,
      searchResult: []
    }
  },
  methods: {
    onSave(content) {
      Toast('save')
      const addr = {}
      addr.id = Math.random().toString().split('.')[1]
      addr.name = content.name
      addr.tel = content.tel
      addr.address = content.province + content.city + content.county + content.addressDetail
      this.$store.commit('address/SET_ADDRESS', addr)
      this.$router.push('/home/address')
    },
    onDelete() {
      Toast('delete')
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          // {
          //   name: '黄龙万科中心',
          //   address: '杭州市西湖区'
          // }
        ]
      } else {
        this.searchResult = []
      }
    }
  }
}
</script>
<style lang="scss" >
.addAddr {
}
</style>
